package org.suk.dp.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:对象结构 <br/>
 * @version V1.0  2017/6/22 16:52  by 石冬冬(dongdong.shi@ucarinc.com) - Heil Hitler
 */
public class ObjectStructure {
    private List<Person> personList = new ArrayList<Person>();
    /**
     * 增加
     * @param person
     */
    public void attach(Person person){
        personList.add(person);
    }

    /**
     * 移除
     * @param person
     */
    public void detach(Person person){
        personList.remove(person);
    }

    /**
     * 显示
     * @param visitor
     */
    public void display(Action visitor){
        for(Person p : this.personList){
            p.accept(visitor);
        }
    }
}
